<?PHP
  error_reporting(NULL); 
  include "utility_functions.php";

  if (!empty($_SESSION['user_id'])) {
    verify_privileges($page_type);
  }
  else {
    if ($current_page != "index.php" and $current_page != "view_event.php" and $current_page != "error_page.php" and $current_page != "register.php") {
	  header("Location:error_page.php");
    }
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <head>
	<title>Volunteer Database</title>
	<link rel="stylesheet" media="screen" type="text/css" href="style.css" />
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  </head>

  <body>
    <div id="container">
      <div id="body_space">
        <div id="header">
		  <div id="logo-block">
		    <!-- type your logo and small slogan here -->
            <p id="logo">Volunteer System<span class="logoblue"></span></p>
		    <p id="slogan">&nbsp;</p>
			<!-- end logo and small slogan -->
		  </div>
		    <!-- login -->
			<div id="definels">
              <div id="login_top">
			<?PHP
			  if (!empty($_SESSION['user_id'])) {
			    echo ("<a href=\"profile.php\">{$_SESSION['user_id']}</a>
		               <form method=\"POST\" action=\"logout_response.php?session_id={$_SESSION['session_id']}\">
                         <input type=\"submit\" value=\"Logout\">
                       </form>
	                   </div>");
			  }
			  else {
				echo ("<p>login:&nbsp;&nbsp;</p>
				       <form name=\"login\" method=\"POST\" action=\"login_response.php\">		
                        <input name=\"user_id\" type=\"text\" value=\"username\" class=\"topinputstyle\" />
			            <p>&nbsp;&nbsp;</p>
		                <div class=\"formspace\"><input name=\"password\" type=\"password\" value=\"password\" class=\"topinputstyle\" /></div>
			            <p>&nbsp;&nbsp;</p>
		                <div class=\"formspace\"><input type=\"submit\" value=\"\" class=\"loginbutton\" /></div>
		               </form>
			           </div>
					   <div id=\"login_error\">");
					   
					   if (!empty($_GET["login_error"])) {
				         echo "<p>{$_GET["login_error"]}</p>";
			           }
			  }
			?>
			</div>
			<!-- end login -->
		  </div>
		  <div class="cls"></div>
  		  <div id="top-nav-bg">
            <div id="top-nav">
			  <!-- start top navigation bar -->
              <ul>
              <?PHP
                echo "<li><a href=\"index.php\">Home</a></li>";
				if (empty($_SESSION['user_id'])) {
                  echo "<li><a href=\"register.php\">Register</a></li>";
                }
                if (!empty($_SESSION['user_id'])) {
                  echo "<li><a href=\"profile.php\">Profile</a></li>";
                }
                echo "<li><a href=\"view_event.php\">View Events</a></li>";
                if ((isset($_SESSION['sflag']) and $_SESSION['sflag'] == "y") or (isset($_SESSION['aflag']) and $_SESSION['aflag'] == "y")) {
                  echo "<li><a href=\"event.php\">Event Management</a></li>";
                }
                if (isset($_SESSION['aflag']) and $_SESSION['aflag'] == "y") {
                  echo "<li><a href=\"user.php\">User Management</a></li>";
                }
              ?>
              </ul>
			  <!-- end top navigation bar -->
            </div>
	      </div>
	    </div>
      </div>
	</div>
